package com.neu;

import java.io.*;
import java.lang.reflect.Method;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @author ：geekvan
 * @date ：2020/11/7 12:31
 */
public class Server {
    public void s1() {//负责界面可视化
        try {
            ServerSocket serverSocket = new ServerSocket(6280);

            while (true) {
                Socket socket = serverSocket.accept();// 侦听并接受到此套接字的连接,返回一个Socket对象
                SocketThread socketThread = new SocketThread(socket);
                socketThread.start();
            }

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    public void s2(){//负责RPC
        try {
            ServerSocket serverSocket = new ServerSocket(6281);

            while (true) {
                Socket socket = serverSocket.accept();// 侦听并接受到此套接字的连接,返回一个Socket对象
                RPCThread socketThread = new RPCThread(socket);
                socketThread.start();
            }

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    public static void main(String[] args) {
        Server server = new Server();
        new Thread(server::s1,"s1").start();
        new Thread(server::s2,"s2").start();
    }
}
